package com.altekis.kanbankaze.client;

import com.allen_sauer.gwt.dnd.client.PickupDragController;
import com.allen_sauer.gwt.dnd.client.util.DragClientBundle;
import com.google.gwt.user.client.ui.AbsolutePanel;

public class CardDragController extends PickupDragController {

	public CardDragController(AbsolutePanel boundaryPanel,
			boolean allowDroppingOnBoundaryPanel) {
		super(boundaryPanel, allowDroppingOnBoundaryPanel);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.allen_sauer.gwt.dnd.client.PickupDragController#dragEnd()
	 */
	@Override
	public void dragEnd() {
		// FIXME: Guarrada per arreglar al fer be el drag controller
		if (!context.draggable.getStyleName().contains("expanded")) {
			if (context.draggable instanceof TaskCardView) {
				context.draggable.addStyleName(TaskCardView.CLASSNAME);
			}
			if (context.draggable instanceof UserStoryCardView) {
				context.draggable.addStyleName(UserStoryCardView.CLASSNAME);
			}
		}
		context.draggable.removeStyleName(DragClientBundle.INSTANCE.css()
				.dragging());
		super.dragEnd();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.allen_sauer.gwt.dnd.client.PickupDragController#dragStart()
	 */
	@Override
	public void dragStart() {
		// FIXME: Guarrada per arreglar al fer be el drag controller
		if (context.draggable instanceof TaskCardView) {
			context.draggable.removeStyleName(TaskCardView.CLASSNAME);
		}
		if (context.draggable instanceof UserStoryCardView) {
			context.draggable.removeStyleName(UserStoryCardView.CLASSNAME);
		}
		super.dragStart();
	}

}
